package com.ttg.utils.connection.handler;

//~--- non-JDK imports --------------------------------------------------------

import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.client.ResponseHandler;
import org.apache.http.util.EntityUtils;

import java.io.IOException;

//~--- JDK imports ------------------------------------------------------------

//~--- classes ----------------------------------------------------------------

/**
 * Class BytesResponseHandler
 * Description
 * Create 2016-02-25 01:04:14 
 * @author Ardy    
 */
public class BytesResponseHandler implements ResponseHandler<byte[]> {

    /**
     * Method handleResponse 
     * Description 说明：
     *
     * @param response 说明：
     *
     * @return 返回值说明：
     *
     * @throws IOException 异常：
     */
    public byte[] handleResponse(HttpResponse response) throws IOException {
        HttpEntity entity = null;
        byte[]     var4;

        try {
            entity = ResponseHandlerHelper.handleNon2xxStatus(response);

            byte[] result = EntityUtils.toByteArray(entity);

            var4 = result;
        } finally {
            EntityUtils.consume(entity);
        }

        return var4;
    }
}


//~ Formatted by Jindent --- http://www.jindent.com
